@extends('admin.layouts.head')
@section('content')
    <body>
    <div id="app">
        <div class="wrapper -header-fixed">

        @include('admin.layouts.navbar')
        @include('admin.layouts.sidebar')

        <!-- 内容页开始-->
            <div class="content-container">
                <div class="container-fluid">
                    <div class="page-content">

                        <nav aria-label="breadcrumb">
                            <ol class="breadcrumb">
                                <li class="breadcrumb-item"><a href="{{ route('admin.dashboard') }}">仪表盘</a></li>
                                <li class="breadcrumb-item active" aria-current="page">游戏采集</li>
                            </ol>
                        </nav>

                        <div class="card">
                            <div class="card-body">

                                <div class="col-lg-3">
                                    <div class="row">
                                        <div class="col-lg-12">
                                            <div class="form-group"><label>采集站点：<small class="text-danger">(注意：采集时间有点长，请耐心等待一会。)</small></label>
                                                <select id="url" class="form-control">
                                                    <!--<option value="http://www.pk555.com/js/sf.js">pk555.com</option>-->
                                                    <option value="http://laomir.com/">laomir.com</option>
                                                    <option value="http://qusf.com/">qusf.com</option>
                                                    <option value="http://9745.com/">9745.com</option>
                                                    <option value="http://945.com/">945.com</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="col-lg-12">
                                            <div class="form-group">
                                                <button onclick="submit()" class="btn btn-primary j-collect">提交</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                            </div> <!-- card-body分页 -->
                        </div> <!-- .card -->

                    </div> <!-- .page-content -->
                </div> <!-- .container-fluid -->
            </div> <!-- .content-container -->
        </div> <!-- .wrapper -->
    </div> <!-- #app -->
    <script src="{{ mix('js/app.js') }}"></script>
    <script src="{{ asset('/js/main.js') }}"></script>
    <script>

        let isLoading = false;

        function submit () {

            if (! $('#url').val()) {
                toast('请选择采集站点');
                return false
            }

            if (isLoading === false) {
                isLoading = true;
                $('.j-collect').addClass('disabled');
                $('.j-collect').html('采集中...');
                axios.post('{{ route('admin.collect.store') }}', {
                    url: $('#url').val()
                })
                    .then(function (response) {
                        isLoading = false;
                        $('.j-collect').removeClass('disabled');
                        $('.j-collect').html('提交');
                        toast(response.data.message);
                    })
                    .catch(function (error) {
                        sLoading = false;
                        $('.j-collect').removeClass('disabled');
                        $('.j-collect').html('提交');
                        $.each(error.response.data.errors, function (index, object) {
                            toast(object[0]);
                            return false;
                        });
                    })
            }
        }
    </script>
    </body>

@endsection
